package com.HeJing.类的成员之三_构造器;

/**
 * ClassName: Person
 * Package: com.HeJing.类的成员之三_构造器
 * Description:
 *
 * @Author: HeJing
 * @Create: 2023-03-24 19:07
 * @Version: 1.0
 */
public class Person {
    // 属性:
    String name;
    int age;

    // 无参构造器:
    public Person() {
        System.out.println("无参构造器的调用");
    }

    // 有参构造器:
    public Person(int a) {
        age = a;
    }

    // 方法:
    public void eat() {
        System.out.println("人吃饭");
    }

    public void sleep(int hour) {
        System.out.println("每天睡" + hour + "个小时");
    }
}



























